import request from '@/utils/request'
// import qs from 'qs'

// 按条件分页查询资源接口
export const getResourcePages = data => {
  return request({
    method: 'POST',
    url: '/boss/resource/getResourcePages',
    data
  })
}

// 查询资源分类接口
export const getResourceCategories = () => {
  return request({
    method: 'GET',
    url: '/boss/resource/category/getAll'
  })
}

// 删除自愿
export function deleteResource(id) {
  return request({
    method: 'DELETE',
    url: `/boss/resource/${id}`
  })
}

// 获取编辑行资源
export function getEditResourceInfo(id) {
  return request({
    method: 'GET',
    url: `/boss/resource/${id}`
  })
}

// 提交编辑
export function updateResource(data) {
  return request({
    method: 'POST',
    url: '/boss/resource/saveOrUpdate',
    data
  })
}

export function getAllCategory() {
  return request({
    method: 'GET',
    url: '/boss/resource/category/getAll'
  })
}

// 获取所有资源并按层级展示
export const getResourcesNodeList = (roleId) => {
  return request({
    method: 'GET',
    url: '/boss/resource/getRoleResources',
    params: {
      roleId
    }
  })
}

// 给角色分配资源
export const allocateRoleResources = data => {
  return request({
    method: 'POST',
    url: '/boss/resource/allocateRoleResources',
    data
  })
}


